import { Column, Entity, JoinTable, ManyToMany, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import { UserAdmin } from '@/modules/businessModule/userAdmin/assets/userAdmin.entity';
import { Menu } from '@/modules/businessModule/menu/assets/menu.entity';

@Entity()
export class Role {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  @ApiProperty({ description: '角色名称' })
  roleName: string;

  @Column({ nullable: true })
  @ApiProperty({ description: '备注' })
  remark?: string;

  @ManyToMany(() => Menu)
  @JoinTable({ name: 'role_menu' })
  @ApiProperty({ description: '菜单', type: () => Menu })
  menu: Menu[];

  @OneToMany(() => UserAdmin, (userAdmin) => userAdmin.role)
  @ApiProperty({ description: '用户', type: () => UserAdmin })
  userAdmin: UserAdmin[];
}
